<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-AAS.
 *
 * PHP-AAS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-AAS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-AAS; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-aas
 * @subpackage  deploy
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */

/**
 * Representation of a login configuration element for a web application,
 * as represented in a <code>&lt;login-config&gt;</code> element in the
 * deployment descriptor.
 */

class LoginConfig {


    // ----------------------------------------------------------- Constructors

    /**
     * Construct a new LoginConfig with the specified properties.
     *
     * @param authMethod The authentication method
     * @param realmName The realm name
     * @param loginPage The login page URI
     * @param errorPage The error page URI
     */
    public function __construct($authMethod = null, $realmName = null,
                       $loginPage = null, $errorPage = null) {

        $this->setAuthMethod($authMethod);
        $this->setRealmName($realmName);
        $this->setLoginPage($loginPage);
        $this->setErrorPage($errorPage);

    }


    // ------------------------------------------------------------- Properties


    /**
     * The authentication method to use for application login.  Must be
     * BASIC, DIGEST, FORM, or CLIENT-CERT.
     */
    private $authMethod = null;

    public function getAuthMethod() {
        return ($this->authMethod);
    }

    public function setAuthMethod($authMethod) {
        $this->authMethod = $authMethod;
    }


    /**
     * The context-relative URI of the error page for form login.
     */
    private $errorPage = null;

    public function getErrorPage() {
        return ($this->errorPage);
    }

    public function setErrorPage($errorPage) {
        $this->errorPage = urldecode($errorPage);
    }


    /**
     * The context-relative URI of the login page for form login.
     */
    private $loginPage = null;

    public function getLoginPage() {
        return ($this->loginPage);
    }

    public function setLoginPage($loginPage) {
        $this->loginPage = urldecode($loginPage);
    }


    /**
     * The realm name used when challenging the user for authentication
     * credentials.
     */
    private $realmName = null;

    public function getRealmName() {
        return ($this->realmName);
    }

    public function setRealmName($realmName) {
        $this->realmName = $realmName;
    }


    // --------------------------------------------------------- Public Methods


    /**
     * Return a function representation of this object.
     */
    public function __toString() {

        $sb = "LoginConfig[";
        $sb .= "authMethod=";
        $sb .= $this->authMethod;
        if ($this->realmName != null) {
            $sb .= ", realmName=";
            $sb .= $this->realmName;
        }
        if ($this->loginPage != null) {
            $sb .= ", loginPage=";
            $sb .= $this->loginPage;
        }
        if ($this->errorPage != null) {
            $sb .= ", errorPage=";
            $sb .= $this->errorPage;
        }
        $sb .= "]";
        return ($sb);

    }


}
?>